import React, { Component } from 'react';
import '../App.less';
import  '../css/Zuzhi.less'
import {observer} from "mobx-react";
import  Mobx from  '../mobx'
import Header from  './Header'
import Footer  from  './Footer'
import Lunbo from  './Lunbo'
import  axios from  'axios'
@observer class Zuzhi extends Component {
    constructor(props) {
        super(props)
        this.state={
            SchoolItems:[],
            Gongzuoshi:[],
            Gongzuofang:[]
        }
    }
    componentWillMount(){
        Mobx.history= this.props.history
    }
    componentDidMount(){
        axios.get('http://www.niuduxiu.com/authentication/findzuzhi.jhtml?cpageNumber=1&cpageSize=1&zpageNumber=1&zpageSize=6&type=2&r='+Math.random())
            .then((item)=>{
               this.setState({
                   Gongzuoshi:item.data.zuzhilist
               })
            })
        axios.get('http://www.niuduxiu.com/authentication/findzuzhi.jhtml?cpageNumber=1&cpageSize=1&zpageNumber=1&zpageSize=6&type=3&r='+Math.random())
            .then((item)=>{
                this.setState({
                    Gongzuofang:item.data.zuzhilist
                })
            })
        axios.get('http://www.niuduxiu.com/authentication/findzuzhi.jhtml?cpageNumber=1&cpageSize=1&zpageNumber=1&zpageSize=6&type=1&r='+Math.random())
            .then((item)=>{
                this.setState({
                    SchoolItems:item.data.zuzhilist
                })
            })
    }
    toSchool(item){
        console.log(item.na.id)
        this.props.history.push('/SchoolDetail/'+item.na.id)
    }
    toZuZhiShi(item){
        this.props.history.push('/Work/1/'+item.na.id)
    }
    toZuZhiFang(item){
        console.log(item)
        this.props.history.push('/Work/2/'+item.na.id)
    }
    ZuzhiIndex(item){
        this.props.history.push('/School/'+item)
    }
    render() {
        return (
            <div className="App">
                <Header />
                <Footer />
                <Lunbo/>
                <div className='Zuzhi'>
                    <p className='title'>创意 · 院 · 校</p>
                    <div className='school'>
                        {
                            this.state.SchoolItems.map((item,index)=>{
                                return(
                                        <div className='schoolOne' key={index} onClick={this.toSchool.bind(this,item)}>
                                            <div className='schoolImg'>
                                                <img src={item.na.raddress} alt=""/>
                                            </div>
                                            <p>{item.na.schoolname}</p>
                                        </div>
                                )
                            })
                        }
                    </div>
                    <p className='LookAll' onClick={this.ZuzhiIndex.bind(this,1)}>查看全部</p>
                    <p className='title'>星 · 工作室</p>
                    <div className='gongzuoshi'>
                        {
                            this.state.Gongzuoshi.map((item,index)=>{
                                return(
                                    <div className='gongzuoshiOne' key={index} onClick={this.toZuZhiShi.bind(this,item)}>
                                        <div className='left'>
                                            <img src={item.na.raddress} alt=""/>
                                        </div>
                                        <div className='right'>
                                            <p>{item.na.teamName}</p>
                                            <div>{item.na.rintroduction}</div>
                                        </div>
                                    </div>
                                )
                            })
                        }
                    </div>
                    <p className='LookAll' onClick={this.ZuzhiIndex.bind(this,2)} >查看全部</p>
                    <p className='title'>名师 · 工作坊</p>
                    <div className='gongzuoshi'>
                        {
                            this.state.Gongzuofang.map((item,index)=>{
                                return(
                                    <div className='gongzuoshiOne' key={index} onClick={this.toZuZhiFang.bind(this,item)}>
                                        <div className='left'>
                                            <img src={item.na.raddress} alt=""/>
                                        </div>
                                        <div className='right'>
                                            <p>{item.na.teamName}</p>
                                            <div>{item.na.rintroduction}</div>
                                        </div>
                                    </div>
                                )
                            })
                        }
                    </div>
                    <p className='LookAll'  onClick={this.ZuzhiIndex.bind(this,3)}>查看全部</p>
                    <p className='title'>和 · 合作机构</p>
                    <div className='heZuoZuZhi'>
                        <img src="http://www.niuduxiu.com/m/static/img/5组织-合作机构-210x210-47.6c9025a.jpg" alt=""/>
                        <img src="http://www.niuduxiu.com/m/static/img/5组织-合作机构-210x210-47.6c9025a.jpg" alt=""/>
                        <img src="http://www.niuduxiu.com/m/static/img/5组织-合作机构-210x210-47.6c9025a.jpg" alt=""/>
                    </div>
                    <p className='noMore'>
                        已经是最低处了哦
                    </p>
                </div>
            </div>
        );
    }
}

export default Zuzhi;
